import Vue from 'vue'
import Router from 'vue-router'
import product from '@/components/pc/product/product'
import shoppingmall from '@/components/pc/shoppingmall/shoppingmall'
import brand from '@/components/pc/brand/brand'
import introduce from '@/components/pc/introduce/introduce'
import newlist from '@/components/pc/newliat/newlist'
import newdetails from '@/components/pc/newdetails/newdetails'


Vue.use(Router);

let router = new Router({
  mode:'history',
  routes: [
    {
      path: '/',
      name: 'product',
      component: product
    },
    {
      path: '/shoppingmall',
      name: 'shoppingmall',
      component: shoppingmall
    },
    {
      path: '/brand',
      name: 'brand',
      component: brand
    },
    {
      path: '/introduce',
      name: 'introduce',
      component: introduce
    },
    {
      path: '/newlist',
      name: 'newlist',
      component: newlist
    },
    {
      path: '/newdetails',
      name: 'newdetails',
      component: newdetails
    },
  ],
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
router.beforeEach((to, from, next) => {
  if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
    window.location.href = '/index.html#/'
    return
  }
  next()
})

export default router
